<?php

namespace App\Models;

use Illuminate\Database\Eloquent\SoftDeletes;
use Slowlyo\OwlAdmin\Models\BaseModel as Model;

/**
 * 动线记录
 */
class HardwareMoveRecord extends Model
{
	// use SoftDeletes;

	protected $table = 'hardware_move_record';
	protected static function boot()
	{
		parent::boot();

		static::creating(function ($model) {
			$model->created_at = date('Y-m-d H:i:s');
			$model->updated_at = date('Y-m-d H:i:s');
			$model->operator_uid = admin_user()->id;
			$model->editor_uid = admin_user()->id;
		});

		static::updating(function ($model) {
			$model->updated_at = date('Y-m-d H:i:s');
			$model->editor_uid = admin_user()->id;
		});
	}

	/**
     * 获取硬件之前位置
     */
    public function afterlocation()
    {
        return $this->belongsTo(LocationCategory::class, 'after_location');
    }
	/**
     * 获取硬件之后位置
     */
    public function prelocation()
    {
        return $this->belongsTo(LocationCategory::class, 'previous_location');
    }

}